<?php

/**
 * This is the model class for table "butaaksara".
 *
 * The followings are the available columns in table 'butaaksara':
 * @property integer $ba_id
 * @property integer $ba_kec
 * @property integer $ba_lakilaki
 * @property integer $ba_perempuan
 * @property integer $ba_jumlah
 * @property integer $ba_tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $baKec
 */
class Butaaksara extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Butaaksara the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'butaaksara';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ba_kec, ba_lakilaki, ba_perempuan, ba_jumlah, ba_tahun', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ba_id, ba_kec, ba_lakilaki, ba_perempuan, ba_jumlah, ba_tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'baKec' => array(self::BELONGS_TO, 'Kecamatan', 'ba_kec'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ba_id' => 'Ba',
			'ba_kec' => 'Ba Kec',
			'ba_lakilaki' => 'Ba Lakilaki',
			'ba_perempuan' => 'Ba Perempuan',
			'ba_jumlah' => 'Ba Jumlah',
			'ba_tahun' => 'Ba Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ba_id',$this->ba_id);
		$criteria->compare('ba_kec',$this->ba_kec);
		$criteria->compare('ba_lakilaki',$this->ba_lakilaki);
		$criteria->compare('ba_perempuan',$this->ba_perempuan);
		$criteria->compare('ba_jumlah',$this->ba_jumlah);
		$criteria->compare('ba_tahun',$this->ba_tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}